package com.xp.code.util;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;

public class WebSession {
	
	protected HttpSession session;
	
	public WebSession(){
		WebContext wt=WebContextFactory.get();
		if(wt!=null){
			session=wt.getSession();
		}else{
			session=ServletActionContext.getRequest().getSession();
		}
		session.setMaxInactiveInterval(-1);
	}
	
	public void setAttribute(String name, Object attr)
	{
		session.setAttribute(name, attr);
	}
	
	public Object getAttribute(String name)
	{
		return session.getAttribute(name);
	}

}
